#ifndef LOGININFOINSTANCE_H
#define LOGININFOINSTANCE_H
#include <QString>

class LoginInfoInstance
{
public:
    LoginInfoInstance(const LoginInfoInstance& obj) = delete;
    LoginInfoInstance& operator=(const LoginInfoInstance& obj) = delete;
    LoginInfoInstance(LoginInfoInstance&& obj) = delete;
    LoginInfoInstance& operator=(LoginInfoInstance&& obj) = delete;

    static LoginInfoInstance* getInstance();

    void setLoginInfo(QString tmpUser, QString tmpIp, QString tmpPort, QString token = "");

    inline QString getUser()const {return user;}
    inline QString getToken()const {return token;}
    inline QString getIp()const {return ip;}
    inline QString getPort()const {return port;}
private:
    LoginInfoInstance() = default;
    ~LoginInfoInstance() = default;

    static LoginInfoInstance* instance;

    QString user;
    QString token;
    QString ip;
    QString port;

private:
    class AutoRelease
    {
    public:
        AutoRelease() = default;
        ~AutoRelease()
        {
            if(LoginInfoInstance::instance == nullptr) return;
            delete LoginInfoInstance::instance;
            LoginInfoInstance::instance = nullptr;
        }
    };
private:
    static AutoRelease _at;
};

#endif // LOGININFOINSTANCE_H
